package com.focus.ctrl.demo.web.maphandler;

import java.util.Date;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.WebRequest;

@Controller
public class LastModifiedController {
	@RequestMapping("testCache")
	@ResponseBody
	public String myHandleMethod(WebRequest webRequest, Model model,
			HttpServletResponse response) {
		long lastModified = (new Date().getTime() - 50 * 1000 * 60 * 6000) * 1000 * 1000; // 1.
		// application-specific
		// calculation
		if (webRequest.checkNotModified(lastModified)) {
			// 2. shortcut exit - no further processing necessary
			return null;
		}
		// 3. or otherwise further request processing, actually preparing
		// content
		model.addAttribute("", "");

		// response.addDateHeader("Last-Modified", lastModified);
		return "testCache";
	}
}
